﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentCourseUT
{
    public class Course
    {
        private string name;
        private SortedSet<Student> students;

        public Course(string name)
        {
            this.name = name;
            this.students = new SortedSet<Student>();
        }

        public string Name
        {
            get
            {
                return name;
            }
        }

        public SortedSet<Student> Students
        {
            get
            {
                return students;
            }
        }

        public void AddStudent(Student student)
        {
            if (this.Students.Contains(student))
            {
                throw new ArgumentException("Student has already joined this course");
            }
            else if (this.students.Count > 30)
            {
                throw new OverflowException("Maximum number of students reached");
            }
            else
            {
                this.students.Add(student);
            }
        }

        public void RemoveStudent(Student student)
        {
            if (this.Students.Contains(student))
            {
                this.students.Remove(student);
            }
            else
            {
                throw new ArgumentNullException("Student hasn't joined the course");
            }
        }
    }
}
